<template>
    <div class="">
        <el-card>
        <el-table v-loading="loading"
                  :data="list"
                  :header-cell-style="{background:'#F4F4F5',color:'#606266'}"
                  border>
            <el-table-column label="全国品牌公司名称" prop="nationCompanyName"  align="center"/>
            <el-table-column label="省级品牌名称"  prop="provinceCompanyName" align="center"/>
            <el-table-column label="市级品牌名称" prop="cityCompanyName" align="center"/>
            <el-table-column label="县级品牌名称"  prop="countryCompanyName" align="center" />
        </el-table></el-card>
    </div>
</template>

<script>
    import {
        getInfo,
        getList,
        getAuthAdmin,
        updateMerchantsCertificationInfo
    } from "../../api/merchantsMergedCompany/merchantsMergedCompany.js";
    const formJson = {
        globabrandname: "", //全球品牌公司名称
        nationwidelbrandname: "", //全国品牌公司名称
        provincebrandname: "", //省级品牌公司名称
        citybrandname: "", //市级品牌公司名称
        countybrandname: "", //县级品牌公司名称
        globaid: "", //品牌所属国家ID
        globaname: "", //品牌所属国家名称
        provinceid: "", //品牌所属省ID
        provincename: "", //品牌所属省名称
        cityid: "", //品牌所属市ID
        cityname: "", //品牌所属市名称
        countyid: "", //品牌所属县ID
        countyname: "", //品牌所属县名称
        memberid: "" //隶属人ID
    };

    export default {
        data() {
            return {
                dateVal: ["2020-10-14", "2020-11-19"],
                list: [],
                query: {
                    currentPage: 1,
                    pageSize: 10,
                },
                authadminlist: [],
                formLoading: false,
                formName: "",
                formMap: {
                    add: "添加",
                    edit: "编辑",
                    detail: "查看"
                },
                infoData:{
                    memberid:"",
                    userid:"",
                    type:"",
                },
                formData: formJson,
                formVisible: false, //添加编辑显示
                loading: false,
                showEditPage: false,
                formRules: {
                    userid: {
                        required: true,
                        message: "请选择",
                        trigger: "blur"
                    }
                },
                formInfo:{},
                dialogTel: false
            };
        },
        methods: {
            editForm(type){
                this.infoData.memberid=this.formInfo.memberid;
                this.infoData.type=type;
                this.dialogTel=true;
             },
            hideEditForm(){
                this.infoData.type="";
                this.infoData.userid="";
                this.dialogTel=false;
            },
            getList() {
                this.loading = true
                getList(this.query)
                    .then((response) => {
                        console.info(response.data)
                        if (response.code) {
                            this.$message.error(response.message)
                        }
                        this.list = response.data.list || []
                        this.totalNumber = response.data.totalNumber || 0
                        setTimeout(() => {
                            this.loading = false
                        }, 0.3 * 1000)
                    })
                    .catch(() => {
                        this.loading = false
                        this.list = []
                        this.totalNumber = 0
                    })
            },
            showEdit(id) {
                this.query.memberid=id;
                this.getInfo();
                this.showEditPage = true;
            },
            getInfo(){
                getInfo({ memberid: this.query.memberid })
                    .then(response => {
                        if (response.code) {
                            this.$message.error(response.message);
                        }
                        console.log(response);
                        this.formInfo = response.data;
                    })
            },
            getAuthAdmin(){
                getAuthAdmin()
                    .then(response => {
                        console.info(response.data)
                        if (response.code) {
                            this.$message.error(response.message);
                        }
                        this.authadminlist = response.data || [];
                    })
                    .catch(() => {
                        this.authadminlist=[];
                    });
            },


            formSubmit() {
                console.info(this.infoData)
                this.$refs["ruleForm"].validate(valid => {
                    if (valid) {
                        this.formLoading = true;
                        updateMerchantsCertificationInfo(this.infoData)
                            .then(response => {
                                this.formLoading = false;
                                if (response.code != 0) {
                                    this.$message.error(response.message);
                                    return false;
                                }
                                this.$message.success("操作成功");
                                this.hideEditForm();
                            })
                            .catch(() => {
                                this.formLoading = false;
                            });
                    }
                });
            },
            handleForm() {
                this.formName = "add";
                this.formVisible = true;
            },
            hideForm() {
                // 更改值
                this.formVisible = !this.formVisible;
                // 清空表单
                this.$refs["ruleForm"].resetFields();
            },
            closeDialog() {
                this.formInfo={};
                this.showEditPage = false;
            },
            onRest() {
                this.query = {
                    name: "",
                    status: "",
                    currentPage: 1,
                    pageSize: 10
                };
                this.getList();
            },
            onSubmit() {
                this.query.currentPage = 1;
                this.getList();
            },


            dateChange() {
                console.log(this.dateVal);
            },
        },
        created() {
            this.getList();
            // this.getCountyBrandList();
        }
    };
</script>

<style scoped lang="scss">
    .showAchievement {
        margin: 30px 0;
        font-size: 16px;
        .achievement {
            padding: 15px 0;
            background-color: rgba(232, 232, 232, 0.3);
            // text-shadow: 5px 5px 5px rgba(255, 140, 0, 1);
            color: rgba(255, 0, 0, 1);
            text-shadow: 1px -1px 1px rgba(255, 0, 0, 1);
            font-weight: 500;
        }
        ul {
            // width: 100%;
            // border-radius: 5px;
            // box-shadow: inset 0 0 5px 1px rgba(0, 0, 0, 0.1);
            border: 1px solid rgba(226, 226, 226, 0.5);
        }
        li {
            text-align: center;
        }
        li + li {
            border-top: 1px solid rgba(226, 226, 226, 0.5);
        }
        .left {
            text-align: center;
            width: 30%;
        }
        .spantite {
            text-align: center;
            width: 20%;
        }
        .rigth {
            text-align-last: left;
            width: 70%;
            text-indent: 2em;
        }
        span {
            padding: 15px 0;
            display: inline-block;
            height: 100%;
        }
        span + span {
            border-left: 1px solid rgba(226, 226, 226, 0.5);
        }
    }
    .el-date-editor--daterange.el-input,
    .el-date-editor--daterange.el-input__inner,
    .el-date-editor--timerange.el-input,
    .el-date-editor--timerange.el-input__inner {
        width: 400px;
        margin: 0 20px;
    }
</style>
